import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { Home, DomTest, LinearPath } from '@/pages'
import { HttpIntercepter, ScrollToTop } from '@/components'
import './index.scss';

class App extends Component {
    render() {
        let isProd = window.location.port.indexOf('30') >= 0;
        return (
            <Router basename={isProd ? "/" : `/`}>
                <HttpIntercepter>
                    <ScrollToTop>
                        <Switch >
                            {/* 首页 */}
                            <Route exact path="/home" component={Home} />
                            {/* dom test */}
                            <Route exact path="/domTest" component={DomTest} />
                            {/* 线性路径 */}
                            <Route exact path="/linearPath" component={LinearPath} />
                            {/* 默认跳转页面 */}
                            <Redirect path="/" to={{ pathname: '/home' }} />
                            
                        </Switch>
                    </ScrollToTop>
                </HttpIntercepter>
            </Router>
        )
    }
}

export default App;
